Skip to content

bhwi-cli: add descriptors pubkeys command#22

Merged
edouardparis merged 1 commit intowizardsardine:mainfrom
trevarj:getdescriptors
Apr 9, 2026
Merged

bhwi-cli: add descriptors pubkeys command#22
edouardparis merged 1 commit intowizardsardine:mainfrom
trevarj:getdescriptors

Conversation

@trevarj
Copy link
Copy Markdown
Collaborator

@trevarj trevarj commented Apr 4, 2026

Analogous to Python HWI's getdescriptors.


Note: HWI uses h instead ' for the paths, so the checksums are different. This isn't possible right now with rust-miniscript

cargo r -- --format json descriptors pubkeys | jq
{
  "internal": [
    "pkh([0f056943/44'/0'/0']tpubDDpWvmUrPZrhSPmUzCMBHffvC3HyMAPnWDSAQNBTnj1iZeJa7BZQEttFiP4DS4GCcXQHezdXhn86Hj6LHX5EDstXPWrMaSneRWM8yUf6NFd/1/*)#j35f7r6v",
    "wpkh([0f056943/84'/0'/0']tpubDCx8y86cKonoPyTtj3f9NZLpBYoBNkbAzUdafMHhggjxkhF8Dny2aekWfDafywEMZEQaQjkK9Gxn7aN7usLRUQdYbvDgcnmYRf72khPEouL/1/*)#fzltz6me",
    "sh(wpkh([0f056943/49'/0'/0']tpubDDbPekoxnr7CaZUbYJVai5nbC2hUKEFeUDddcqhjQkeNo8wqk7qY1MuxDjBGwPESKui5XEH6hu21VfBXJbn8PZrFuwasiDAcyfA7Ao8WAsA/1/*))#cdnlkxr8",
    "tr([0f056943/86'/0'/0']tpubDCrr3F1M4TwZdFptiTXmjHpcdQMYNBzM9vA3gLGtB5tYUL6CFeNNNoK89xxqFowY9jzUsTDfZirSmfy9ZnjBuNVfxLYthQXoVvr3ja1jRrA/1/*)#tzygl3dl"
  ],
  "receive": [
    "pkh([0f056943/44'/0'/0']tpubDDpWvmUrPZrhSPmUzCMBHffvC3HyMAPnWDSAQNBTnj1iZeJa7BZQEttFiP4DS4GCcXQHezdXhn86Hj6LHX5EDstXPWrMaSneRWM8yUf6NFd/0/*)#r93grk25",
    "wpkh([0f056943/84'/0'/0']tpubDCx8y86cKonoPyTtj3f9NZLpBYoBNkbAzUdafMHhggjxkhF8Dny2aekWfDafywEMZEQaQjkK9Gxn7aN7usLRUQdYbvDgcnmYRf72khPEouL/0/*)#ck62l0tp",
    "sh(wpkh([0f056943/49'/0'/0']tpubDDbPekoxnr7CaZUbYJVai5nbC2hUKEFeUDddcqhjQkeNo8wqk7qY1MuxDjBGwPESKui5XEH6hu21VfBXJbn8PZrFuwasiDAcyfA7Ao8WAsA/0/*))#dvafwekc",
    "tr([0f056943/86'/0'/0']tpubDCrr3F1M4TwZdFptiTXmjHpcdQMYNBzM9vA3gLGtB5tYUL6CFeNNNoK89xxqFowY9jzUsTDfZirSmfy9ZnjBuNVfxLYthQXoVvr3ja1jRrA/0/*)#6kpfzya8"
  ]
}

@trevarj trevarj requested a review from edouardparis April 4, 2026 05:49
@edouardparis
Copy link
Copy Markdown
Member

edouardparis commented Apr 7, 2026

I do not think it is part of the bhwi device commands scope, which should be reserved for commands like listing devices, getting firmware version and updating firmware.

I think it should be part of its own commands set, like:

bhwi descriptor list
bhwi descriptor register
bhwi descriptor get

etc

@trevarj
Copy link
Copy Markdown
Collaborator Author

trevarj commented Apr 7, 2026

I do not think it is part of the bhwi device commands scope, which should be reserved for commands like listing devices, getting firmware version and updating firmware.

I think it should be part of its own commands set, like:

bhwi descriptor list
bhwi descriptor register
bhwi descriptor get

etc

Nice, I like that too. Let me fix it up.

@trevarj
Copy link
Copy Markdown
Collaborator Author

trevarj commented Apr 7, 2026

@edouardparis changed to what you said above - cargo r -- descriptor list

@edouardparis
Copy link
Copy Markdown
Member

the command descriptor list is just a wrapper on top of get xpub that list the "common" descriptors.
But as a user, I expect it to list the registered descriptors (which is not possible for some hardware wallets), too. I do not know if we should change the command name, or simply document it.

@trevarj
Copy link
Copy Markdown
Collaborator Author

trevarj commented Apr 8, 2026

the command descriptor list is just a wrapper on top of get xpub that list the "common" descriptors.

@edouardparis Right, just wanted to work towards parity with Python HWI. They're just descriptors for pubkeys it seems.

Maybe deeper commands like descriptor list pubkeys, descriptor list registered ?

Or:
descriptor list <- common pubkey descriptors
descript list --registered <-- actually registered within device

@edouardparis
Copy link
Copy Markdown
Member

edouardparis commented Apr 8, 2026

descriptor list pubkeys or descriptor pubkeys are fine for me for now, we can reserve the descriptor list for later.

serde_json::json!(
{
"receive": receive,
"internal": internal
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what means internal ? is it the change ?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. I can change it but I wanted parity with HWI. I actually like "change" better but internal is fine too

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Funny that "internal" makes sense for the case of utxos refresh to reset timelocks, while "change" relates to a transactional exchange. I agree to keep it as it is.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried and I got same result than your PR description.
Internal and receive are the same set of xpubs, is it the hwi behavior ?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@edouardparis same xpubs but path should have 1 for internal and 0 for receive.

Coldcard simulator:
(ignore checksum difference cause of the h vs ')

     Running `/home/trev/Workspace/rust-projects/bhwi/target/debug/bhwi --format json descriptor pubkeys`
{
  "internal": [
    "pkh([0f056943/44'/0'/0']tpubDDpWvmUrPZrhSPmUzCMBHffvC3HyMAPnWDSAQNBTnj1iZeJa7BZQEttFiP4DS4GCcXQHezdXhn86Hj6LHX5EDstXPWrMaSneRWM8yUf6NFd/1/*)#j35f7r6v",
    "wpkh([0f056943/84'/0'/0']tpubDCx8y86cKonoPyTtj3f9NZLpBYoBNkbAzUdafMHhggjxkhF8Dny2aekWfDafywEMZEQaQjkK9Gxn7aN7usLRUQdYbvDgcnmYRf72khPEouL/1/*)#fzltz6me",
    "sh(wpkh([0f056943/49'/0'/0']tpubDDbPekoxnr7CaZUbYJVai5nbC2hUKEFeUDddcqhjQkeNo8wqk7qY1MuxDjBGwPESKui5XEH6hu21VfBXJbn8PZrFuwasiDAcyfA7Ao8WAsA/1/*))#cdnlkxr8",
    "tr([0f056943/86'/0'/0']tpubDCrr3F1M4TwZdFptiTXmjHpcdQMYNBzM9vA3gLGtB5tYUL6CFeNNNoK89xxqFowY9jzUsTDfZirSmfy9ZnjBuNVfxLYthQXoVvr3ja1jRrA/1/*)#tzygl3dl"
  ],
  "receive": [
    "pkh([0f056943/44'/0'/0']tpubDDpWvmUrPZrhSPmUzCMBHffvC3HyMAPnWDSAQNBTnj1iZeJa7BZQEttFiP4DS4GCcXQHezdXhn86Hj6LHX5EDstXPWrMaSneRWM8yUf6NFd/0/*)#r93grk25",
    "wpkh([0f056943/84'/0'/0']tpubDCx8y86cKonoPyTtj3f9NZLpBYoBNkbAzUdafMHhggjxkhF8Dny2aekWfDafywEMZEQaQjkK9Gxn7aN7usLRUQdYbvDgcnmYRf72khPEouL/0/*)#ck62l0tp",
    "sh(wpkh([0f056943/49'/0'/0']tpubDDbPekoxnr7CaZUbYJVai5nbC2hUKEFeUDddcqhjQkeNo8wqk7qY1MuxDjBGwPESKui5XEH6hu21VfBXJbn8PZrFuwasiDAcyfA7Ao8WAsA/0/*))#dvafwekc",
    "tr([0f056943/86'/0'/0']tpubDCrr3F1M4TwZdFptiTXmjHpcdQMYNBzM9vA3gLGtB5tYUL6CFeNNNoK89xxqFowY9jzUsTDfZirSmfy9ZnjBuNVfxLYthQXoVvr3ja1jRrA/0/*)#6kpfzya8"
  ]
}
➜ ./hwi.py --emulators --fingerprint "0f056943" getdescriptors | jq  
{
  "receive": [
    "pkh([0f056943/44h/0h/0h]tpubDDpWvmUrPZrhSPmUzCMBHffvC3HyMAPnWDSAQNBTnj1iZeJa7BZQEttFiP4DS4GCcXQHezdXhn86Hj6LHX5EDstXPWrMaSneRWM8yUf6NFd/0/*)#s5whevah",
    "wpkh([0f056943/84h/0h/0h]tpubDCx8y86cKonoPyTtj3f9NZLpBYoBNkbAzUdafMHhggjxkhF8Dny2aekWfDafywEMZEQaQjkK9Gxn7aN7usLRUQdYbvDgcnmYRf72khPEouL/0/*)#t89494uz",
    "sh(wpkh([0f056943/49h/0h/0h]tpubDDbPekoxnr7CaZUbYJVai5nbC2hUKEFeUDddcqhjQkeNo8wqk7qY1MuxDjBGwPESKui5XEH6hu21VfBXJbn8PZrFuwasiDAcyfA7Ao8WAsA/0/*))#fuwje7w6"
  ],
  "internal": [
    "pkh([0f056943/44h/0h/0h]tpubDDpWvmUrPZrhSPmUzCMBHffvC3HyMAPnWDSAQNBTnj1iZeJa7BZQEttFiP4DS4GCcXQHezdXhn86Hj6LHX5EDstXPWrMaSneRWM8yUf6NFd/1/*)#pqtkyed0",
    "wpkh([0f056943/84h/0h/0h]tpubDCx8y86cKonoPyTtj3f9NZLpBYoBNkbAzUdafMHhggjxkhF8Dny2aekWfDafywEMZEQaQjkK9Gxn7aN7usLRUQdYbvDgcnmYRf72khPEouL/1/*)#6nq5cqv6",
    "sh(wpkh([0f056943/49h/0h/0h]tpubDDbPekoxnr7CaZUbYJVai5nbC2hUKEFeUDddcqhjQkeNo8wqk7qY1MuxDjBGwPESKui5XEH6hu21VfBXJbn8PZrFuwasiDAcyfA7Ao8WAsA/1/*))#uaqyppm9"
  ]
}

@trevarj trevarj changed the title bhwi-cli: add GetDescriptors command bhwi-cli: add descriptors pubkeys command Apr 8, 2026
@trevarj
Copy link
Copy Markdown
Collaborator Author

trevarj commented Apr 8, 2026

@edouardparis changed to descriptor pubkeys. Thanks

@trevarj trevarj requested a review from edouardparis April 8, 2026 17:51
Comment thread bhwi/src/common/commands/get_descriptor.rs Outdated
@edouardparis
Copy link
Copy Markdown
Member

while running with ledger testnet app:

Error: hwi device error: interpreter error: unexpected result: []

Caused by:
    0: interpreter error: unexpected result: []
    1: unexpected result: []

Which makes sense the ledger testnet app refuses derivation paths for mainnet.

Analogous to Python HWI's getdescriptors.
@trevarj
Copy link
Copy Markdown
Collaborator Author

trevarj commented Apr 9, 2026

while running with ledger testnet app:

Error: hwi device error: interpreter error: unexpected result: []

Caused by:
    0: interpreter error: unexpected result: []
    1: unexpected result: []

Which makes sense the ledger testnet app refuses derivation paths for mainnet.

Not a nice error message 😩
Error message will need to be reworked somehow I think. Need more context there.

@edouardparis edouardparis merged commit a59d289 into wizardsardine:main Apr 9, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants